<?php

use think\migration\Migrator;
use think\migration\db\Column;

class RefundOrderDetail extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('refund_order_detail', ['comment' => '访单退货单记录详情']);
        $table->addColumn('ro_id', 'integer', ['comment' => '访单退货申请单ID', 'limit' => 11, 'default' => 0])
            ->addColumn('cod_id', 'integer', ['comment' => '公司销售订单详情', 'limit' => 11, 'default' => 0])
            ->addColumn('transfer_num', 'integer', ['comment' => '退货数量', 'limit' => 11, 'default' => 0])
            ->addColumn('dealer_goods_id', 'integer', ['comment' => '商品ID', 'limit' => 11, 'default' => 0])
            ->addColumn('dealer_goods_spec_id', 'integer', ['comment' => '规格', 'limit' => 11, 'default' => 0])
            ->addColumn('create_time', 'integer', ['default' => null, 'limit' => 10, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['default' => null, 'limit' => 10, 'comment' => '更新时间'])
            ->addIndex('dealer_goods_id', ['name' => 'idx_dealer_goods_id'])
            ->addIndex('dealer_goods_spec_id', ['name' => 'idx_dealer_goods_spec_id'])
            ->addIndex('ro_id', ['name' => 'idx_ro_id'])
            ->create();
    }
}
